package com.wdl.flink.test

import org.apache.flink.api.scala._

object WordCountByFlink {

  def main(args: Array[String]): Unit = {
    val environment = ExecutionEnvironment.getExecutionEnvironment

    val value: DataSet[String] = environment.readTextFile("E:\\work\\FlinkTutorial\\data\\words")

    val resault: AggregateDataSet[(String, Int)] =
      value
        .flatMap(_.split(" "))
        .map((_, 1))
        .groupBy(0)
        .sum(1)

    resault.collect().foreach(print)

  }
}
